﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Evan.WebUI
{
    /// <summary>
    /// 回收站管理
    /// </summary>
    public class RecycleManager : ManagerPage
    {
        /// <summary>
        /// 表名称
        /// </summary>
        protected string TableName = "";
        /// <summary>
        /// 
        /// </summary>
        protected Evan.Model.SysModel.PageModels List = new Model.SysModel.PageModels();
        /// <summary>
        /// 
        /// </summary>
        protected List<dynamic> Lists = new List<dynamic>();
        /// <summary>
        /// 
        /// </summary>
        protected int PageSize = Convert.ToInt32(Evan.Common.CommFun.GetAppSetting("Admin_PageSize"));
        /// <summary>
        /// 
        /// </summary>
        protected int CurPage = 1;
        /// <summary>
        /// 
        /// </summary>
        protected string key = "";

        /// <summary>
        /// 回收站管理
        /// </summary>
        public RecycleManager()
        {
            this.Load += new EventHandler(RecycleManager_Load);
        }

        private void RecycleManager_Load(object sender, EventArgs e)
        {
            TableName = Common.CommFun.GetQueryString("t");
            int.TryParse(Common.CommFun.GetQueryString("page"), out CurPage);
            int.TryParse(Common.CommFun.GetQueryString("classid"), out ClassId);
            string where = " States=-1 ";
            key = Common.CommFun.GetQueryString("key");
            if (!string.IsNullOrEmpty(key))
            {
                where += string.Format("and (Title like '%{0}%') ", key);
            }

            if (string.IsNullOrEmpty(TableName))
            {
                throw new Exception("参数 t 不能为空");
            }

            
            
           
            if (ClassId > 0)
            {
                if (TableName == "Module") //栏目
                {
                    where += " and ChannelId=" + ClassId;
                }
                else
                {
                    where += " and ClassId=" + ClassId;
                }
                string curChannelOrderBy = Template.TemplateHelper.GetSqlOrderStr(CurChannel);

                //List = new Evan.DataBase.DbOperat(TableName).GetPage(PageSize, CurPage, where, "SortId Desc,Id Desc"); //bll.Page(PageSize, CurPage > 0 ? CurPage : 1, where, " id desc");
                List = new Evan.DataBase.DbOperat(TableName).GetPage_2(PageSize, CurPage, where, curChannelOrderBy,true); //bll.Page(PageSize, CurPage > 0 ? CurPage : 1, where, " id desc");    
            }
            else
            {
                List = new Evan.DataBase.DbOperat(TableName).GetPage_2(PageSize, CurPage, where, "Id Desc", true);
            }

            


        }
    }


}
